<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/2/28
 * Time: 14:42
 */

namespace app\admin\controller;

use app\admin\model\GoodsCate as GoodsCateModel;
use app\admin\traits\Crud;
use app\admin\validate\CateValidate;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;


class Cate extends BaseAdminController
{
    private GoodsCateModel $model;
    use Crud;

    public function initialize()
    {
        parent::initialize();
        $this->model             = new GoodsCateModel;
        $this->validateClass     = CateValidate::class;
    }

    /**
     * @return Response
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function list(): Response
    {
        $param = $this->request->param();
        $sql = $this->model->where('pid', 0)->field('id,name,status');
        $list = $sql->withSearch('status',$param)->select();
        return $this->success('获取成功', $list);
    }


}